///
/// Override the ${Export Button}_Click and customize the
/// export button functionality
/// Also if the export button is Image button then, second parameter type is ImageClickEventArgs.
/// If the button is of "Button" type then modify the parameter type to EventArgs.
///
public override void ${Export Button}_Click(object sender, ImageClickEventArgs args)
{
try {
DbUtils.StartTransaction();
WhereClause wc = CreateWhereClause();
OrderBy orderBy = null;
orderBy = CreateOrderBy();
// Add each of the columns in order of export.
// Replace "Column1, Column2 and so on" with the actual column names which you want to export to CSV file.
// For example :
// BaseColumn[] columns = new BaseColumn[] {
// Order_DetailsTable.OrderID,
// Order_DetailsTable.ProductID,
// Order_DetailsTable.UnitPrice,
// Order_DetailsTable.Quantity,
// Order_DetailsTable.Discount,
// null};
BaseColumn[] columns = new BaseColumn[] {
${Table Name}Table.Column1,
${Table Name}Table.Column2,
${Table Name}Table.Column3,
${Table Name}Table.Column4,
${Table Name}Table.Column5,
null};
// If you do not want Iron Speed Designer generated column hadings then, list the column headings of your choice here.
// The column headings provided in displayColumn will be displayed in exported CSV file instead of Iron Speed Designer generated columns headings.
// Note that even if you are changing one column's heanding, you need to provide all the columns' heanding as a comma separated list.
string displayColumn = "Order Id, Product code, Unit Price, Qunatity, Discount";
ExportData rep = new ExportData(${Table Name}Table.Instance, wc, orderBy, columns, displayColumn);
rep.ExportToCSV(this.Page.Response);
this.Page.CommitTransaction(sender);
} catch (Exception ex) {
this.Page.RollBackTransaction(sender);
this.Page.ErrorOnPage = true;
BaseClasses.Utils.MiscUtils.RegisterJScriptAlert(this, "BUTTON_CLICK_MESSAGE", ex.Message);
} finally {
DbUtils.EndTransaction();
}
}
|